package mutsumimod.cards.stand.specialstand;

import com.badlogic.gdx.graphics.Color;
import com.megacrit.cardcrawl.actions.common.GainBlockAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import mutsumimod.cards.BaseCard;
import mutsumimod.character.Mutsumi;
import mutsumimod.powers.BlindPower;
import mutsumimod.powers.StandPower;
import mutsumimod.util.CardStats;
import mutsumimod.util.GeneralUtils;

//TODO 使用3次后消耗
public class ThreeDays extends BaseCard {
    public static final String ID = makeID(ThreeDays.class.getSimpleName());
    public static final CardStats info = new CardStats(
            Mutsumi.Meta.CARD_COLOR,
            CardType.SKILL,
            CardRarity.RARE,
            CardTarget.SELF,
            1
    );

    public int useCountLeft;
    public final static int MAX_TIME=3;


    public ThreeDays() {
        super(ID, info);
        setAttr(0,10,0);
        setAttrUpg(0,2,0);
        setCustomVar("MT", MAX_TIME);
        useCountLeft = MAX_TIME;
        updateDescription();
    }

    @Override
    public void updateDescription() {
        setCustomVar("UC", useCountLeft);
        rawDescription=cardStrings.DESCRIPTION;
        if(GeneralUtils.isInCombat()){
            rawDescription+=cardStrings.EXTENDED_DESCRIPTION[0];
        }
        initializeDescription();
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        stand(3,m);
        stand(5,m);
        stand(7,m);
        useCountLeft--;
        if (useCountLeft <= 0) {
            exhaust = true;
        }
        updateDescription();
    }

    @Override
    public void triggerOnGlowCheck() {
        int amount=0;
        if(AbstractDungeon.player.hasPower(StandPower.POWER_ID)){
            amount=AbstractDungeon.player.getPower(StandPower.POWER_ID).amount;
        }
        if(amount>=3||AbstractDungeon.player.hasPower(BlindPower.POWER_ID)){
            glowColor = Color.GOLD.cpy();
            return;
        }
        super.triggerOnGlowCheck();
    }

    @Override
    public void standUse3(AbstractPlayer p, AbstractMonster m) {
        addToTop(new GainBlockAction(p,block));
    }

    @Override
    public void standUse5(AbstractPlayer p, AbstractMonster m) {
        addToTop(new GainBlockAction(p,block));
    }

    @Override
    public void standUse7(AbstractPlayer p, AbstractMonster m) {
        addToTop(new GainBlockAction(p,block));
    }

    @Override
    public ThreeDays makeStatEquivalentCopy() {
        ThreeDays threeDays = (ThreeDays) super.makeStatEquivalentCopy();
        threeDays.useCountLeft = this.useCountLeft;
        threeDays.updateDescription();
        return threeDays;
    }

    @Override
    public AbstractCard makeCopy() {
        return new ThreeDays();
    }
}
